<template>
  <div>
    <h2>Tab</h2>
    <p>{{ count }}</p>
    <button @click="add">增加</button>
    <button @click="sub">减少</button>
    <button @click="getMovieList">获取数据</button>
    <ul>
      <li v-for="item in movieList" :key="item.id">{{ item.albumName }}</li>
    </ul>
  </div>
</template>

<script>
import { mapActions, mapMutations, mapState } from "vuex";
export default {
  name: "Tab",
  mounted() {
    console.log(this.$store.state.count);
  },
  computed: {
    ...mapState(["count", "movieList"]),
  },
  methods: {
    // 通过辅助函数 拿到所有的mutation内修改state的方法
    ...mapMutations(["add", "sub"]),
    ...mapActions(["getMovieList"]),
  },
};
</script>

<style>
</style>